<template>
  <div class="menu">
    <scroll>
      <ul class="menu-list">
        <li
          v-for="(item, index) in menu"
          :key="index"
          @click="menuClick(index)"
          :class="{ action: currentIndex === index }">
          {{ item.title }}
        </li>
      </ul>
    </scroll>
  </div>
</template>

<script>
import Scroll from "components/common/scroll/Scroll";

export default {
  name: "CateMenu",
  components: {
    Scroll,
  },
  props: {
    menu: {
      type: Array,
      default() {
        return [];
      },
    },
  },
  data() {
    return {
      currentIndex: 0,
    };
  },
  methods: {
    menuClick(index) {
      this.currentIndex = index;

      this.$emit('selectItem',this.currentIndex)
    },
  },
};
</script>

<style scoped>
.menu {
  width: 100%;
  height: 100%;
  background-color: #fff;
  font-size: 14px;
}
.menu-list {
  width: 100%;
  height: 45px;
  line-height: 45px;
  text-align: center;
}
.action {
  color: hotpink;
  border-left: 3px solid hotpink;
  font-weight: 600;
  background: #f6f6f6;
}
</style>
